A pinhole is widely used as a component to direct or collimate incident light in an optical system. In the semiconductor industry, to fabricate a high-speed, high-efficiency optical sensor by complementary metal oxide semiconductor (CMOS)-compatible technologies has drawn much research effort. However, to integrate the pinhole in the optical sensor generally requires an additional fabrication step, frequently non-CMOS-compatible, or/and an additional component to reach an optimal performance of the optical sensor.